<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>{append}</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Smarty 3 Manual">
<link rel="up" href="language.builtin.functions.html" title="Chapter 7. Built-in Functions">
<link rel="prev" href="language.builtin.functions.html" title="Chapter 7. Built-in Functions">
<link rel="next" href="language.function.assign.html" title="{assign}">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">{append}</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="language.builtin.functions.html">Prev</a> </td>
<th width="60%" align="center">Chapter 7. Built-in Functions</th>
<td width="20%" align="right"> <a accesskey="n" href="language.function.assign.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="{append}">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="language.function.append"></a>{append}</h2></div></div></div>
<p>
   <code class="varname">{append}</code> is used for creating or appending template variable arrays
   <span class="bold"><strong>during the execution  of a template</strong></span>.
 </p>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>
   Assignment of variables in-template is essentially placing application logic into the presentation that may be better handled in PHP. Use at your own discretion.
 </p>
</div>
<p><span class="bold"><strong>Attributes:</strong></span></p>
<div class="informaltable"><table border="1">
<colgroup>
<col align="center">
<col align="center">
<col align="center">
<col align="center">
<col>
</colgroup>
<thead><tr>
<th align="center">Attribute Name</th>
<th align="center">Type</th>
<th align="center">Required</th>
<th align="center">Default</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td align="center">var</td>
<td align="center">string</td>
<td align="center">Yes</td>
<td align="center"><span class="emphasis"><em>n/a</em></span></td>
<td>The name of the variable being assigned</td>
</tr>
<tr>
<td align="center">value</td>
<td align="center">string</td>
<td align="center">Yes</td>
<td align="center"><span class="emphasis"><em>n/a</em></span></td>
<td>The value being assigned</td>
</tr>
<tr>
<td align="center">index</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center"><span class="emphasis"><em>n/a</em></span></td>
<td>The index for the new array element.
      If not specified the value is append to the end of the array.</td>
</tr>
<tr>
<td align="center">scope</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center"><span class="emphasis"><em>n/a</em></span></td>
<td>The scope of the assigned variable: 'parent','root' or 'global'</td>
</tr>
</tbody>
</table></div>
<p><span class="bold"><strong>Option Flags:</strong></span></p>
<div class="informaltable"><table border="1">
<colgroup>
<col align="center">
<col>
</colgroup>
<thead><tr>
<th align="center">Name</th>
<th>Description</th>
</tr></thead>
<tbody><tr>
<td align="center">nocache</td>
<td>Assigns the variable with the 'nocache' attribute</td>
</tr></tbody>
</table></div>
<div class="example">
<a name="id364932"></a><p class="title"><b>Example 7.7. {append}</b></p>
<div class="example-contents">
<pre class="programlisting">

{append var='name' value='Bob' index='first'}
{append var='name' value='Meyer' index='last'}
// or 
{append 'name' 'Bob' index='first'} {* short-hand *}
{append 'name' 'Meyer' index='last'} {* short-hand *}

The first name is {$name.first}.&lt;br&gt;
The last name is {$name.last}.

  </pre>
<p>
   The above example will output:
  </p>
<pre class="screen">

The first name is Bob.
The last name is Meyer.

  </pre>
</div>
</div>
<br class="example-break"><p>
 See also <a class="link" href="api.append.html" title="append()"><code class="varname">append()</code></a>
   and
  <a class="link" href="api.get.template.vars.html" title="getTemplateVars()"><code class="varname">getTemplateVars()</code></a>.
 </p>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="language.builtin.functions.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="language.builtin.functions.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="language.function.assign.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Chapter 7. Built-in Functions </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> {assign}</td>
</tr>
</table>
</div>
</body>
</html>
